using UnityEngine;
using System.Collections;
using System.Collections.Generic;

public class ItemManager : MonoBehaviour {
	
	public static ItemManager Instance {
		get;
		private set;
	}
	
	public void Awake(){
		Instance = this;
	}
	
	public int _shoppingListSize;
	public int _shuffleDepth;
	//public Item [] _allItems;
	
	private List<Item> createShuffledList(){
		
		List<Item> shuffledList = new List<Item>();
		
		foreach ( Transform child in transform) {
			shuffledList.Add (child.GetComponent<Item>());
		}

		//suffle list
		for (int count = 0; count < _shuffleDepth; count++) {
			
			int placeOne = Random.Range (0, shuffledList.Count);
			int placeTwo = Random.Range (0, shuffledList.Count);
			
			Item tempItem = shuffledList[placeTwo];
			shuffledList[placeTwo] = shuffledList[placeOne];
			shuffledList[placeOne] = tempItem;
		}
		
		return shuffledList;
	}
	
	
	public Item [] GetShoppingList(int listSize){
		
		List<Item> shuffledList = createShuffledList();
		Item [] newShoppingList = new Item[listSize];
		
		//create shopping list
		for (int count = 0; count < listSize; count++) {
				newShoppingList[count] = shuffledList[count];		
		}	
		
		return newShoppingList;
		
	}
	
	public Dictionary<Item, int> GetShoppPriceList() {
		List<Item> shuffledList = createShuffledList();
		Dictionary<Item, int> shopPriceList = new Dictionary<Item, int>();
						
		//create shopping list
		for (int count = 0; count < _shoppingListSize && count < shuffledList.Count; count++) {
			//print(shuffledList[count].name);
			shopPriceList.Add(shuffledList[count], Random.Range (10, 50));
		}
		
		return  shopPriceList;
	}
	
		public Dictionary<Item, int> GetShoppPriceList(int shoppingListSize) {
		List<Item> shuffledList = createShuffledList();
		Dictionary<Item, int> shopPriceList = new Dictionary<Item, int>();
						
		//create shopping list
		for (int count = 0; count < shoppingListSize && count < shuffledList.Count; count++) {
			//print(shuffledList[count].name);
			shopPriceList.Add(shuffledList[count], Random.Range (10, 50));
		}
		
		return  shopPriceList;
	}
	
}